#ifndef __DIRECTOR_HPP__
#define __DIRECTOR_HPP__

#include "builder1.hpp"
#include "builder2.hpp"

class Director {
public:
	Director() : m_builder(NULL) {cout<<__func__<<endl;}
	~Director();
	Product *productInfo(char ch);
private:
	AbstractBuilder *m_builder;
};

inline Director::~Director()
{
	cout<<__func__<<endl;
	if (m_builder) {
		delete m_builder;
		m_builder = NULL;
	}
}

inline Product *Director::productInfo(char ch)
{
	if (m_builder) {
		delete m_builder;
		m_builder = NULL;
	}

	if ('A' == ch) {
		m_builder = new Builder1();
	} else if ('B' == ch) {
		m_builder = new Builder2();
	} else {
		return NULL;
	}

	m_builder->buildCoolDish("CoolDish");
	m_builder->buildDrink("Drink");
	m_builder->buildRice("Rice");

	return m_builder->getProduct();
}

#endif /* end of include guard */
